#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Create by Albert_Chen
# CopyRight (py) 2017年 陈超. All rights reserved by Chao.Chen.
# Create on 2017-01-19

from __future__ import absolute_import

import logging
import datetime
from celery.utils.log import get_task_logger
from .celery import app
from .functions.send_mail import make_excel


logger = get_task_logger('__name__')


@app.task(name='report.send')
def report_send():

    today = datetime.datetime.now()
    yesterday = today - datetime.timedelta(days=1)

    today_str = today.strftime('%Y-%m-%d')
    yesterday_str = yesterday.strftime('%Y-%m-%d')
    logger.info('start make excel')
    make_excel(today=today_str, yesterday=yesterday_str)